package Data;

import java.util.LinkedList;
import GUI.*;

public class Lines {
	private static Lines instance = new Lines();
	public static Lines getInstance() {
		return instance;
	}
	protected Lines() {
		lines = new LinkedList();
	}
	
	private LinkedList<Line> lines;
	
	public void add(Line l){
			lines.add(l);
	}
	
	public void remove(Line l){
			lines.remove(l);
	}
	
	public void remove(ClassFrame cf1, ClassFrame cf2) throws Exception {
		try {
			int size = lines.size();
			for (int i = 0; i < size; i++) {
				if ((lines.get(i).getHead().equals(cf1) && lines.get(i).getTail().equals(cf2))
					|| (lines.get(i).getHead().equals(cf2) && lines.get(i).getTail().equals(cf1))) {
					lines.remove(i);
					size--;
				}
			}
		} catch (Exception e) {
			throw e;
		}
	}
	
	public LinkedList<Line> getLines() {
		return lines;
	}
}
